package org.linys.dao.dict;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
import org.linys.model.dict.GoodsType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@SuppressWarnings("unchecked")
@Repository
public class GoodsTypeDAO {
	private SqlSession sqlSession;
	@Autowired
	public void setSqlSession(SqlSession sqlSession) {
		this.sqlSession = sqlSession;
	}
	
	public GoodsType selectTreeRoot() {
		return (GoodsType) sqlSession.selectOne("GoodsTypeMapper.selectTreeRoot");
	}
	
	public List<GoodsType> selectTreeNode(GoodsType goodsType) {
		return (List<GoodsType>) sqlSession.selectList("GoodsTypeMapper.selectTreeNode",goodsType);
	}

	public int count(GoodsType goodsType) {
		return (Integer) sqlSession.selectOne("GoodsTypeMapper.count",goodsType);
	}

	public List<GoodsType> getTreeNodeTabel(GoodsType goodsType, Integer start,
			Integer rows) {
		return (List<GoodsType>) sqlSession.selectList("GoodsTypeMapper.getTreeNodeTabel",goodsType,new RowBounds(start,rows));
	}

	public int save(GoodsType goodsType) {
		return sqlSession.insert("GoodsTypeMapper.insert", goodsType);
	}

	public int deleteByGoodsTypeID(Integer id) {
		return sqlSession.delete("GoodsTypeMapper.deleteByGoodsTypeID", id);
	}

	public int update(GoodsType goodsType) {
		return sqlSession.update("GoodsTypeMapper.update", goodsType);
	}

	public int countChoose(GoodsType goodsType) {
		return (Integer) sqlSession.selectOne("GoodsTypeMapper.countChoose",goodsType);
	}

	public List<GoodsType> viewChoose(GoodsType goodsType, Integer start,
			Integer rows) {
		return (List<GoodsType>) sqlSession.selectList("GoodsTypeMapper.viewChoose",goodsType,new RowBounds(start,rows));
	}


}
